const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
const VueLoaderPlugin = require("vue-loader/lib/plugin");

module.exports = {
  // mode: "development",
  entry: "./src/main.js",
  output: {
    filename: "js/bundle.js",
    publicPath: "/",
  },
  // devServer: {
  //   contentBase: "public",
  //   open: true,
  //   port: 8085,
  // },
  module: {
    rules: [
      {
        test: /\.less$/,
        use: ["style-loader", "css-loader", "less-loader"],
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        use: {
          loader: "url-loader",
          options: {
            esModule: false,
            limit: 10 * 1024, // 10 KB
            name: "img/[name].[hash:7].[ext]",
          },
        },
      },
      {
        test: /\.css$/,
        use: ["vue-style-loader", "css-loader"],
      },
      {
        test: /\.vue$/,
        use: {
          loader: "vue-loader",
        },
      },
    ],
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: "Hello Webpack",
      template: "./public/index.html",
    }),
    new webpack.DefinePlugin({
      BASE_URL: JSON.stringify("/"),
    }),
    new VueLoaderPlugin(),
  ],
};
